package com.net.xpay.openapi.protocol;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.net.common.util.SerializationUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
public class OpenApiResult<T> {

    //如果data为null就不参与序列化字符串了
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @ApiModelProperty(notes = "data")
    private String data;

    @ApiModelProperty(notes = "响应码")
    private String resultCode = "0";

    @ApiModelProperty(notes = "响应描述")
    private String resultMessage = "处理成功";

    @JsonInclude(JsonInclude.Include.NON_NULL)
    @ApiModelProperty(notes = "签名")
    private String sign;

    public OpenApiResult(T data) {
        this.data = SerializationUtil.obj2String(data);
    }

    public OpenApiResult(String resultCode, String resultMessage) {
        this.resultCode = resultCode;
        this.resultMessage = resultMessage;
    }
}
